//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.example.zqathserver.controller;

import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
public class DingTalkController {
    public DingTalkController() {
    }

    @GetMapping({"/gettoken"})
    public Map<String, Object> getToken(@RequestParam String appkey, @RequestParam String appsecret) {
        Map<String, Object> response = new HashMap();
        if ("appId111".equals(appkey) && "appSecret111".equals(appsecret)) {
            response.put("errcode", 0);
            response.put("access_token", "96fc7a7axxx");
            response.put("errmsg", "ok");
            response.put("expires_in", 7200);
        } else {
            response.put("errcode", 400);
            response.put("errmsg", "invalid appkey or appsecret");
        }

        return response;
    }

    @PostMapping({"/topapi/v2/user/getuserinfo"})
    public Map<String, Object> getUserInfo(@RequestParam String access_token, @RequestBody Map<String, String> body) {
        Map<String, Object> response = new HashMap();
        String code = (String)body.get("code");
        if ("access_token111".equals(access_token) && "code111".equals(code)) {
            response.put("errcode", 0);
            response.put("errmsg", "ok");
            response.put("request_id", "e8krly4vyiln");
            Map<String, Object> result = new HashMap();
            result.put("userid", "hyf");
            result.put("name", "黄逸凡");
            result.put("mobile", "123456789");
            response.put("result", result);
        } else {
            response.put("errcode", 400);
            response.put("errmsg", "invalid access_token or code");
        }

        return response;
    }
}
